package com.siriframe.cloud.home.dynamic;

import com.siriframe.cloud.home.dynamic.adapter.AliStorageAdapter;
import com.siriframe.cloud.home.dynamic.adapter.MinioStorageAdapter;
import com.siriframe.cloud.home.dynamic.adapter.StorageAdapter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@RefreshScope
public class TestConfig {

    @Value("${storage.service.type}")
    public String storageType;

    @Bean
    @RefreshScope
    public StorageAdapter storageService() {
        System.out.println(storageType);
        if ("minio".equals(storageType)) {
            System.out.println(storageType);
            return new MinioStorageAdapter();
        } else if ("aliyun".equals(storageType)) {
            System.out.println(storageType);
            return new AliStorageAdapter();
        } else {
            throw new IllegalArgumentException("未找到对应的文件存储处理器");
        }
    }
}
